package com.lyy.converter;

import com.lyy.Vo.ProductCategoryTreeNodeVO;
import com.lyy.system.entity.ProductCategory;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 商品类别转换
 */
public class ProductCategoryConverter {

    /**
     * 转树节点
     * @param productCategories
     * @return
     */
    public static List<ProductCategoryTreeNodeVO> converterToTreeNodeVO(List<ProductCategory> productCategories){
        List<ProductCategoryTreeNodeVO> productCategoryTreeNodeVOS =new ArrayList<>();
        if (!CollectionUtils.isEmpty(productCategories)){
            for (ProductCategory productCategory:productCategories){
                ProductCategoryTreeNodeVO productCategoryTreeNodeVO=new ProductCategoryTreeNodeVO();
                BeanUtils.copyProperties(productCategory,productCategoryTreeNodeVO);
                productCategoryTreeNodeVOS.add(productCategoryTreeNodeVO);
            }
        }
        return productCategoryTreeNodeVOS;
    }
}
